Advanced Debugging
About AdvDbg Consult Train Services Products Tools Community Contact  
欢迎光临 高端调试 登录 | 注册 | FAQ
 
  ACPI调试
Linux内核调试
Windows内核调试
 
  调试战役
调试原理
新工具观察
 
  Linux
Windows Vista
Windows
 
  Linux驱动
WDF
WDM
 
  PCI Express
PCI/PCI-X
USB
无线通信协议
 
  64位CPU
ARM
IA-32
  CPU Info Center
 
  ACPI标准
系统认证
Desktop
服务器
 
  Embedded Linux
嵌入式开发工具
VxWorks
WinCE
嵌入式Windows
 
  格蠹调试套件(GDK)
  格蠹学院
  小朱书店
  老雷的微博
  《软件调试》
  《格蠹汇编》
  《软件调试(第二版)》
沪ICP备11027180号-1

WinDbg

帖子发起人: tonyYe   发起时间: 2012-07-16 13:00 下午   回复: 1

Print Search
帖子排序:    
   2012-07-16, 13:00 下午
TonyYe 离线,最后访问时间: 2010/3/15 6:36:26 tonyYe

发帖数前500位
注册: 2010-03-15
发 贴: 3
关于空指针访问错误
Reply Quote
我用下面的测试代码。
class a
{
public:
void Test(){ s+= 3;}
int s;
int t;
};

void HHH(int s,int t,int i)
{
a *p = new a;
delete p;
p = NULL;
p->Test();
}

这个程序运行的时候在p->Test崩溃。用windbg分析下,它提示的exception是
EXCEPTION_RECORD:  0012f3c0 -- (.exr 0x12f3c0)
ExceptionAddress: 0040151f (EccomVdsTes!HHH+0x0000000f)
   ExceptionCode: c0000005 (Access violation)
  ExceptionFlags: 00000000
NumberParameters: 2
   Parameter[0]: 00000001
   Parameter[1]: 00000000
Attempt to write to address 00000000
为什么显示这个参数(NumberParameters: 2)有两个啊?

IP 地址: 已记录   报告
   2012-07-17, 12:37 下午
Raymond 离线,最后访问时间: 2020/7/3 3:40:25 格蠹老雷

发帖数前10位
注册: 2005-12-19
发 贴: 1,303
Re: 关于空指针访问错误
Reply Quote
在EXCEPTION_RECORD Structure的SDK文档中解释的很清楚:   NumberParameters

The number of parameters associated with the exception. This is the number of defined elements in the ExceptionInformation array.

ExceptionInformation

An array of additional arguments that describe the exception. The RaiseException function can specify this array of arguments. For most exception codes, the array elements are undefined. The following table describes the exception codes whose array elements are defined.

Exception code Meaning
EXCEPTION_ACCESS_VIOLATION

The first element of the array contains a read-write flag that indicates the type of operation that caused the access violation. If this value is zero, the thread attempted to read the inaccessible data. If this value is 1, the thread attempted to write to an inaccessible address. If this value is 8, the thread causes a user-mode data execution prevention (DEP) violation.

The second array element specifies the virtual address of the inaccessible data.

EXCEPTION_IN_PAGE_ERROR

The first element of the array contains a read-write flag that indicates the type of operation that caused the access violation. If this value is zero, the thread attempted to read the inaccessible data. If this value is 1, the thread attempted to write to an inaccessible address. If this value is 8, the thread causes a user-mode data execution prevention (DEP) violation.

The second array element specifies the virtual address of the inaccessible data.

The third array element specifies the underlying NTSTATUS code that resulted in the exception.


IP 地址: 已记录   报告
高端调试 » 软件调试 » WinDbg » 关于空指针访问错误

 
Legal Notice Privacy Statement Corporate Governance Corporate Governance
(C)2004-2020 ADVDBG.ORG All Rights Reserved.